<%-- 
    Document   : request_transferencia
    Created on : 21/10/2011, 04:56:58 PM
    Author     : Jose
--%>

<%@ page import="PaquetesJL.*" %>
<%@page import="java.sql.ResultSet" %>

<%
    int id_emisor=Integer.parseInt(request.getParameter("id_emisor"));        
    int id_cheque=Integer.parseInt(request.getParameter("id_cheque"));        
    float monto=0;
    boolean montovalido=true;
    
    try{
        monto=Float.parseFloat(request.getParameter("monto").replace(",", "."));
    }catch(Exception e){
        montovalido=false;
    }
    
    if(!montovalido || monto<=0){
        out.println("El monto que ingreso es invalido."+request.getParameter("monto"));
    }else{
        String sqlServer = pageContext.getServletContext().getInitParameter("sqlServer");
        String databaseName = pageContext.getServletContext().getInitParameter("databaseName");
        String userName = pageContext.getServletContext().getInitParameter("userName");
        String PasswordP = pageContext.getServletContext().getInitParameter("password");
        String Backup = pageContext.getServletContext().getInitParameter("RutaBackup");

        byte[] decodedBytes = ConexionBD.decode(PasswordP);
        String decodedPassword = new String(decodedBytes).trim();

        ConexionBD Conexion = new ConexionBD(sqlServer, databaseName, userName, decodedPassword, Backup);
        Conexion.IniciarConexion();
        ResultSet r=Conexion.EjecutarConsulta("EXEC dbo.CobroCheque "+id_emisor+","+id_cheque+","+monto+",0");                               
        if(r.next()){
            out.print(r.getString(1));     
        }   

        Conexion.CerrarConexion();
    }                 
%>
